package com.bskj.kuaifu.nettyService.protobuf;

import java.io.IOException;

import com.bskj.kuaifu.nettyService.protobuf.analysis.ParseMap;
import com.bskj.kuaifu.nettyService.protobuf.generate.cli2srv.register.Register;
import com.bskj.kuaifu.nettyService.protobuf.generate.server2cli.rail.Rail;
import com.google.protobuf.Message;

/**
 * Created by Qzy on 2016/1/30.
 */
public class ParseRegistryMap {
	public static final int REQUEST_REQUEST = 1000;

	public static final int UP_RAIL = 2000;
	public static final int REQUEST_RESPONE = 2001;

	public static void initRegistry() throws IOException {
		ParseMap.register(REQUEST_REQUEST, new ParseMap.Parsing() {
			public Message process(byte[] bytes) throws IOException {
				return Register.Resquest.parseFrom(bytes);
			}
		}, Register.Resquest.class);

		ParseMap.register(REQUEST_RESPONE, new ParseMap.Parsing() {
			public Message process(byte[] bytes) throws IOException {
				return com.bskj.kuaifu.nettyService.protobuf.generate.server2cli.register.Register.Resp
						.parseFrom(bytes);
			}
		}, com.bskj.kuaifu.nettyService.protobuf.generate.server2cli.register.Register.Resp.class);

		ParseMap.register(UP_RAIL, new ParseMap.Parsing() {
			public Message process(byte[] bytes) throws IOException {
				return Rail.UpRail.parseFrom(bytes);
			}
		}, Rail.UpRail.class);
	}
}
